Skip to content

fix(ralph): harden repo-root resolution in verify-hooks-e2e#102

Merged
jaruesink merged 1 commit intomainfrom
codex/2026-02-05-verify-hooks-repo-root-fix
Feb 5, 2026
Merged

fix(ralph): harden repo-root resolution in verify-hooks-e2e#102
jaruesink merged 1 commit intomainfrom
codex/2026-02-05-verify-hooks-repo-root-fix

Conversation

@jaruesink
Copy link
Copy Markdown
Contributor

@jaruesink jaruesink commented Feb 5, 2026

Summary\n- resolve repo root using /Users/jaruesink/projects/devagent anchored from script location\n- add explicit error when repo root cannot be resolved\n- update usage comments to reflect invocation no longer depends on caller cwd\n\n## Why\nThis makes the E2E verifier resilient to caller working directory assumptions and prepares safer extraction from PR #100 without merging it.\n\n## File\n- .devagent/plugins/ralph/tools/verify-hooks-e2e.sh

Summary by CodeRabbit

  • Chores
    • Improved robustness of testing infrastructure with enhanced repository root resolution and error handling.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

The bash script's repository root resolution logic was refactored to use Git's rev-parse --show-toplevel command instead of static directory traversal. Error handling was added to detect and report resolution failures, with an early exit on failure.

Changes

Cohort / File(s) Summary
Git-based repo root resolution
.devagent/plugins/ralph/tools/verify-hooks-e2e.sh
Replaced directory traversal with git rev-parse --show-toplevel for robust REPO_ROOT determination; added error handling and early exit on resolution failure.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A git-based hop, so clean and so right,
No more wandering paths in the night!
With rev-parse's true call, the root now shines bright,
And errors caught early—what a delight! ✨

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: hardening repo-root resolution in the verify-hooks-e2e script, which is confirmed by the summary and objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/2026-02-05-verify-hooks-repo-root-fix

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.devagent/plugins/ralph/tools/verify-hooks-e2e.sh:
- Around line 13-16: The git invocation that computes REPO_ROOT should use
SCRIPT_DIR directly instead of the hard-coded "../../../../.." traversal; change
the command that sets REPO_ROOT (the line using git -C and rev-parse) to run git
-C "${SCRIPT_DIR}" rev-parse --show-toplevel so it reliably resolves the repo
root from the script location, keeping the existing error check and
processLogger-style echo/exit behavior intact.

Comment on lines +13 to +16
if ! REPO_ROOT="$(git -C "${SCRIPT_DIR}/../../../../.." rev-parse --show-toplevel 2>/dev/null)"; then
echo "Error: Unable to resolve repo root from ${SCRIPT_DIR}" >&2
exit 1
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Redundant path traversal undermines the git-based approach.

git rev-parse --show-toplevel resolves the repository root from any location within the repo. The manual ../../../../.. navigation is unnecessary and reintroduces the brittleness you're trying to eliminate—if the script ever moves, this path breaks.

♻️ Proposed fix: use SCRIPT_DIR directly
-if ! REPO_ROOT="$(git -C "${SCRIPT_DIR}/../../../../.." rev-parse --show-toplevel 2>/dev/null)"; then
+if ! REPO_ROOT="$(git -C "${SCRIPT_DIR}" rev-parse --show-toplevel 2>/dev/null)"; then
   echo "Error: Unable to resolve repo root from ${SCRIPT_DIR}" >&2
   exit 1
 fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ! REPO_ROOT="$(git -C "${SCRIPT_DIR}/../../../../.." rev-parse --show-toplevel 2>/dev/null)"; then
echo "Error: Unable to resolve repo root from ${SCRIPT_DIR}" >&2
exit 1
fi
if ! REPO_ROOT="$(git -C "${SCRIPT_DIR}" rev-parse --show-toplevel 2>/dev/null)"; then
echo "Error: Unable to resolve repo root from ${SCRIPT_DIR}" >&2
exit 1
fi
🤖 Prompt for AI Agents
In @.devagent/plugins/ralph/tools/verify-hooks-e2e.sh around lines 13 - 16, The
git invocation that computes REPO_ROOT should use SCRIPT_DIR directly instead of
the hard-coded "../../../../.." traversal; change the command that sets
REPO_ROOT (the line using git -C and rev-parse) to run git -C "${SCRIPT_DIR}"
rev-parse --show-toplevel so it reliably resolves the repo root from the script
location, keeping the existing error check and processLogger-style echo/exit
behavior intact.

@jaruesink jaruesink merged commit 9277371 into main Feb 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant